home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-20 | 3.4 KB | 150 lines | [TEXT/CWIE] |
- //Copyright (c) 1997 Aidan Cully
- //All rights reserved
-
- #include <Dialogs.h>
- #include "MenuHandler.h"
- #include "CLApplication.h"
- #include "ConicContent.h"
- #include "ConicViewManager.h"
- #include "DrawContent.h"
- #include "CLOffScreen.h"
- #include "EquNew.h"
- #include "CLWindowLayer.h"
- #include "CLModalWindow.h"
- #include "AboutContent.h"
-
- TConicHandler::TConicHandler( Boolean hasDD, MActionHandler *superAction ):
- MActionHandler( superAction )
- {
- mConicWindow = 0l;
- mControlWindow = 0l;
- mEquWindow = 0l;
- mPlotWindow = 0l;
- mHasDragDrop= hasDD;
- }
-
- TConicHandler::~TConicHandler()
- {
- delete mConicWindow;
- delete mControlWindow;
- delete mEquWindow;
- delete mPlotWindow;
- }
-
- SInt8 TConicHandler::Init()
- {
- MenuHandle appleMenu;
- Handle theMBar = GetNewMBar( 128 );
- TLayoutLeaf *layout;
- Rect begRect;
- Boolean binding[]= {true, true, true, true};
-
- mConic.Init();
- mPlane.Init();
- ::SetRect( &begRect, 0, 0, 0, 0 );
-
- layout= new TConicContent( 0, this, mHasDragDrop, &mConic, &mPlane, -50.0, -55.0 );
- //layout= new TScrollStyleBox( 0, 128 );
- layout->Init();
- mConicWindow = new TOffScreen( kConicWindowID, gNormalWindowLayer, layout );
- layout= new TPlotContent( 0, this, mHasDragDrop, &mConic, &mPlane );
- layout->Init();
- mPlotWindow = new TOffScreen( kPlotWindowID, gNormalWindowLayer, layout );
- layout= new TEquContent( 0, this, mHasDragDrop, &mPlane );
- layout->Init();
- mEquWindow = new TOffScreen( kEquWindowID, gNormalWindowLayer, layout );
- layout= new TViewManagerHolder( 0, &mConic, &mPlane );
- layout->Init();
- mControlWindow = new TBaseWindow( kControlWindowID, gFloatingWindowLayer, layout );
- mControlWindow->Init();
- mConicWindow->Init();
- mPlotWindow->Init();
- mEquWindow->Init();
-
- mPlane.RotPlane();
- mConic.CalcIntersect( mPlane );
- mControlWindow->DoShowWindow();
- mEquWindow->DoShowWindow();
- mPlotWindow->DoShowWindow();
- mConicWindow->DoShowWindow();
- mConicWindow->SelectWindow();
-
- SetMenuBar( theMBar );
- if( theMBar ) {
- appleMenu = GetMenuHandle( m_APPLE );
- DisposeHandle( theMBar );
- AppendResMenu( appleMenu, 'DRVR' );
- DrawMenuBar();
- return( true );
- }
- return( false );
- }
-
- SInt8 TConicHandler::HandleAction( UInt32 actionID )
- {
- UInt16 theMenu, menuID;
-
- theMenu = (actionID>>16);
- menuID = (actionID&0x0000FFFF);
- switch( theMenu ) {
- case m_APPLE:
- switch( menuID )
- {
- case ma_ABOUT: {
- TModalWindow *win;
- TLayoutLeaf *content= new TAboutContent( 0 );
- content->Init();
- win= new TModalWindow( 130, content );
- win->EventLoop();
- delete win;
- }; break;
- default:
- OpenDeskAcc( actionID );
- break;
- }
- break;
- case m_FILE:
- switch( menuID )
- {
- case mf_CLOSE: {
- TBaseWindow *win= gNormalWindowLayer->FrontWindow();
- if( !win ) {
- WindowRef ref= FrontWindow();
- if( ref )
- win= ((TBaseWindow*)GetWRefCon( ref ));
- }
- if( win )
- win->DoHideWindow();
- }; break;
- case mf_QUIT:
- TApplication::SCurApp()->AttemptQuit();
- break;
- }
- break;
- case m_WINDOW:
- switch( menuID )
- {
- case mw_CONIC:
- if( !mConicWindow->IsOpen() )
- mConicWindow->DoShowWindow();
- mConicWindow->SelectWindow();
- break;
- case mw_PLOT:
- if( !mPlotWindow->IsOpen() )
- mPlotWindow->DoShowWindow();
- mPlotWindow->SelectWindow();
- break;
- case mw_CONTROL:
- if( !mControlWindow->IsOpen() )
- mControlWindow->DoShowWindow();
- break;
- case mw_EQU:
- if( !mEquWindow->IsOpen() )
- mEquWindow->DoShowWindow();
- mEquWindow->SelectWindow();
- break;
- }
- break;
- }
- HiliteMenu( 0 );
- }